<%--
  Created by IntelliJ IDEA.
  User: chenhs
  Date: 2020/2/27
  Time: 9:40
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@include file="common/tag.jsp" %>
<%@include file="common/head.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

    <title>书刊集</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">


    <script type="javascript">

        function appoint(bookId, studentId) {
            //定义变量sendData
            var sendData ={studentId: studentId};
            $.ajax({
                url: basePath + '/book/appoint/'+bookId,
                type:'post',
                dataType:'json',
                contentType:"application/json",
                async:true,//异步请求
                cache:false,
                data:JSON.stringify(sendData),//使用变量sendData
                //执行成功的回调函数
                success:function(data) {
                    alert(data.data);
                },
                //执行失败或错误的回调函数
                error:function(data) {
                    alert("认证失败");
                }
            });
        }
    </script>

</head>

<body>



<c:forEach items="${requestScope.list}" var="book" >
    ${book.bookId}-${book.name}-${book.number}<br>
</c:forEach>

<table  width="600" border="1" cellpadding="0" >
    <tr>
        <th>ID</th>
        <th>书名</th>
        <th>库存</th>
        <th>操作</th>
    </tr>
    <c:forEach var="book" items="${requestScope.list}"  >
        <form action="UpdateServlet" method="post">
            <tr>
                <td><input type="text" value="${book.bookId}" name="id" ></td>
                <td><input type="text" value="${book.name}" name="name"></td>
                <td><input type="text" value="${book.number}" name="num"></td>
                <td><a href="book/detail/${book.bookId}" target="_blank">详情</a> <a href="javascript:void(0);" onclick="appoint(${book.bookId}, 110);">借阅</a> </td>
            </tr>
        </form>
    </c:forEach>
</table>

</body>
</html>
